#ifndef SCREENPTR_H
#define SCREENPTR_H
/*
 overload member access operator arrow make a class behavior like a pointer.
 It's often used with a class that represents a "smart pointer".
 Let's look at an example and explain how it works:
 pointer->action();
 step 1:
 if pointer is a pointer to object of some class type, build-in member access operator arrow is used;
 if pointer is a object or a reference to object, the object's type is examined to find out whether a overloaded
 member access arrow is defined. If defined, the compiler use this overloaded version, otherwise, an error is ocurred,
 since an object without overloaded member access operator arrow should use member access operator dot.

 step 2:
 return value of the overloaded member access opeartor arrow could be either a pointer or object.
 if return value is a pointer, the build-in member access operator arrow is used to access function action() in object poninted by the result;
 if return value is a object, step 1 is processed recursivly until an error ocurred or a pointer is returned.

*/
class Screen;
class ScreenPtr{
public:
	//ScreenPtr(Screen &s):ptr(&s){}
	ScreenPtr(Screen &s,int arraySize=0):ptr(&s),size(arraySize),offset(0){}
	Screen& operator*(){return *ptr;}
	Screen* operator->(){return ptr;}
	Screen& operator++();//prefix
	Screen& operator--();//prefix
	Screen& operator++(int);//postfix
	Screen& operator--(int);//postfix
private:
	Screen *ptr;
	int size;
	int offset;
};
#endif